<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$q = $_GET["q"];
include '../../../../readcookie.php';
include '../../../../db.php';

$tmids= "SELECT tmTAGID FROM TagMenu WHERE tmMENUID = '" . $q . "'";


$tres=mysql_query($tmids);


$cntres = mysql_num_rows($tres);

if ($cntres != 0){
$cntres -= 1;
$newselect = "SELECT tagID, tagNAME FROM Tag";
$cnt = 0;

while($trow=mysql_fetch_array($tres)){
    
    if ($cnt == 0) {
        $newselect .= " WHERE ";
    }

    $tid = $trow['tmTAGID'];
    $selectvar.= "tagID = '" . $tid . "'";
    if ($cnt <  $cntres){
    $selectvar .= " OR ";
    }
    $cnt += 1;
}

$newselect .= $selectvar;
$r=mysql_query($newselect);

while($row=mysql_fetch_array($r)){
    $tag = $row['tagID'];
    $tthing = $row['tagNAME'];
    $tagstring .= "<OPTION VALUE=\"$tag\">" . $tthing;
}
echo'
<form><select name="eventID" onchange="showSub(this.value)">
<OPTION VALUE=0>Select Tag...',$tagstring,'</select>
</form><br />
<div id="txtHint3"><b>
</b></div>';
} else {
echo "<h4>No Tags assigned to this menu</h4>";
}

?>
